

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/favicon.png">
  <link rel="icon" href="/img/favicon.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="风间">
  <meta name="keywords" content="">
  
    <meta name="description" content="私有仓库是一种为开发者和团队提供内部库的机制，它可以使开发者更好地管理和共享内部代码，并将一些第三方库缓存下来以减少重复的下载">
<meta property="og:type" content="article">
<meta property="og:title" content="使用 Nexus 搭建 Maven 私有仓库">
<meta property="og:url" content="http://example.com/2023/05/08/%E5%90%8E%E7%AB%AF/java/nexus%E6%90%AD%E5%BB%BA%E7%A7%81%E6%9C%89%E4%BB%93%E5%BA%93/index.html">
<meta property="og:site_name" content="风间小栈">
<meta property="og:description" content="私有仓库是一种为开发者和团队提供内部库的机制，它可以使开发者更好地管理和共享内部代码，并将一些第三方库缓存下来以减少重复的下载">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://s3.bmp.ovh/imgs/2023/04/26/c995d127fc2b3eeb.png">
<meta property="article:published_time" content="2023-05-08T01:46:03.862Z">
<meta property="article:modified_time" content="2023-05-08T01:46:03.862Z">
<meta property="article:author" content="风间">
<meta property="article:tag" content="maven">
<meta property="article:tag" content="私有仓库">
<meta property="article:tag" content="Nexus">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://s3.bmp.ovh/imgs/2023/04/26/c995d127fc2b3eeb.png">
  
  
  <title>使用 Nexus 搭建 Maven 私有仓库 - 风间小栈</title>

  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4/github-markdown.min.css" />
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hint.css@2/hint.min.css" />

  
    
    
      
      <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@10/styles/github-gist.min.css" />
    
  

  
    <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.css" />
  


<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.8.13","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"right","visible":"hover","icon":"§"},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"copy_btn":true,"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
<meta name="generator" content="Hexo 5.4.0"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>风间小栈</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner" id="banner" parallax=true
         style="background: url('/img/%E6%96%87%E6%9C%AC.jpg') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="page-header text-center fade-in-up">
            <span class="h2" id="subtitle" title="使用 Nexus 搭建 Maven 私有仓库">
              
            </span>

            
              <div class="mt-3">
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2023-05-08 09:46" pubdate>
        2023年5月8日 上午
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      4k 字
    </span>
  

  
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      34 分钟
    </span>
  

  
  
    
      <!-- 不蒜子统计文章PV -->
      <span id="busuanzi_container_page_pv" style="display: none">
        <i class="iconfont icon-eye" aria-hidden="true"></i>
        <span id="busuanzi_value_page_pv"></span> 次
      </span>
    
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">使用 Nexus 搭建 Maven 私有仓库</h1>
            
            <div class="markdown-body">
              <blockquote>
<p>阅读提示：本文内容是基于 <font color="red">nexus-3.19.1-01</font> 版本！！！</p>
</blockquote>
<h2 id="1-什么是-Maven-私有仓库"><a href="#1-什么是-Maven-私有仓库" class="headerlink" title="1. 什么是 Maven 私有仓库"></a>1. 什么是 Maven 私有仓库</h2><p>在开发过程中，我们通常会使用Maven构建项目的依赖管理系统。Maven的仓库是用来存放各种软件库、框架和插件等资源的地方，它可以让我们方便地管理各种依赖，并且可以通过依赖关系自动下载所需的库文件，缩短编译部署时间，提高效率。</p>
<p>但是，对于企业内部开发者和团队而言，与外部库不同，他们可能需要创建一些定制的依赖项，如共享的基础框架、工具类、代码库等。这时，Maven 私有仓库就派上用场了。私有仓库是一种为开发者和团队提供内部库的机制，它可以使开发者更好地管理和共享内部代码，并将一些第三方库缓存下来以减少重复的下载。</p>
<p><strong>常用的构件私有仓库的软件</strong>：</p>
<ol>
<li>Apache Archiva  </li>
<li>JFrog Artifactory</li>
<li><font color="red">Sonatype Nexus</font>：也就是本文要介绍使用的搭建 maven 私服的软件<a target="_blank" rel="noopener" href="https://www.sonatype.com/">官网</a></li>
</ol>
<p><img src="https://s3.bmp.ovh/imgs/2023/04/24/9a3f21f187ac0a19.png" srcset="/img/loading.gif" lazyload></p>
<h2 id="2-Nexus简介"><a href="#2-Nexus简介" class="headerlink" title="2. Nexus简介"></a>2. Nexus简介</h2><p>Nexus是一个流行的二进制管理工具，它由 Sonatype 开发，可以作为 Maven、NuGet 和 Docker 等多种包管理器的仓库管理器。Nexus 可以提供一个中央储存库，供开发人员共享依赖项，同时还可以提供私有仓库功能，使企业能够更好地管理内部资源。</p>
<p>Nexus 有许多可定制的选项，可以帮助您配置Maven私有仓库以满足您的特定需求。本文将提供详细的 Nexus 搭建和配置指南，快速搭建属于自己的 Maven 私有仓库。</p>
<h2 id="3-Nexus-搭建"><a href="#3-Nexus-搭建" class="headerlink" title="3. Nexus 搭建"></a>3. Nexus 搭建</h2><h3 id="3-1-安装-Java-环境"><a href="#3-1-安装-Java-环境" class="headerlink" title="3.1 安装 Java 环境"></a>3.1 安装 Java 环境</h3><p>在安装Nexus之前，需要确保已经安装了Java环境（JDK 8或更高版本）。你可以在终端输入以下命令来检查是否已安装Java环境：</p>
<figure class="highlight applescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs applescript">java -<span class="hljs-built_in">version</span><br></code></pre></td></tr></table></figure>

<p>如果系统已安装Java环境，将会输出Java版本信息。否则，需要先安装Java。</p>
<h3 id="3-2-下载-Nexus-传送门"><a href="#3-2-下载-Nexus-传送门" class="headerlink" title="3.2 下载 Nexus 传送门"></a>3.2 下载 Nexus <a target="_blank" rel="noopener" href="https://www.sonatype.com/thanks/repo-oss?hsCtaTracking=bde424ac-b77c-4799-913d-9d0db86ef1f8%7Cb308aaca-ab41-4544-ba23-c53c1b469e0d">传送门</a></h3><p><img src="https://s3.bmp.ovh/imgs/2023/04/24/369d6e28beed20f7.png" srcset="/img/loading.gif" lazyload></p>
<p><img src="https://s3.bmp.ovh/imgs/2023/04/24/87f61e3e18c7bbb4.png" srcset="/img/loading.gif" lazyload></p>
<h3 id="2-3-运行"><a href="#2-3-运行" class="headerlink" title="2.3 运行"></a>2.3 运行</h3><ol>
<li>切换到 nexus-3.19.1-01 的 bin 目录下</li>
</ol>
<ul>
<li><p>mac/linux平台执行命令: <code>./nexus run</code></p>
</li>
<li><p>windows平台执行命令:<code>nexus /run</code></p>
</li>
</ul>
<p><strong><font color="red">tips</font></strong>: </p>
<ul>
<li><p>run 是前台启动，可以看到实时的启动日志，start 是后台启动；</p>
</li>
<li><p>启动如果遇到数据库（DB）相关的错误，可以删除 sonatype-work/nexus3/db 文件夹，重新启动；</p>
</li>
<li><p>还有一个问题是当前用户的权限不足，使用管理员角色运行即可</p>
</li>
</ul>
<ol start="2">
<li>nexus 默认端口号 <code>8081</code> ，启动成功后可直接访问 <a target="_blank" rel="noopener" href="http://localhost:8081/">http://localhost:8081/</a></li>
</ol>
<ul>
<li>新建仓库需登录后方可操作，默认账号 <code>admin</code>，密码存放路径 <code>/sonatype-work/nexus3/admin.password</code>  </li>
<li>登录成功后需修改密码</li>
</ul>
<p><img src="https://s3.bmp.ovh/imgs/2023/04/24/76adc1ac899eae3c.png" srcset="/img/loading.gif" lazyload></p>
<h2 id="3-Nexus-内置仓库"><a href="#3-Nexus-内置仓库" class="headerlink" title="3. Nexus 内置仓库"></a>3. Nexus 内置仓库</h2><h3 id="3-1-三种类型"><a href="#3-1-三种类型" class="headerlink" title="3.1 三种类型"></a>3.1 三种类型</h3><ul>
<li><p><code>proxy</code>: （代理）用来代理远程仓库，是介于远程仓库和本地仓库之间的私有仓库</p>
<ul>
<li>依赖存储策略：release，只会下载和存中央仓库中的发布版本依赖</li>
</ul>
</li>
<li><p><code>group</code>: （仓库组）对我们的仓库进行分组管理</p>
<ul>
<li>依赖存储策略：release，只会下载和存中央仓库中的发布版本依赖</li>
</ul>
</li>
<li><p><code>hosted</code>：（宿主）用于发布我们本地开发的项目，将项目发布到 hosted 仓库后再进行相关的部署工作</p>
<ul>
<li>依赖存储策略，release：用于存储稳定版本项目，snapshot: 用于发布快照版本软件</li>
</ul>
</li>
</ul>
<h3 id="3-2-内置仓库"><a href="#3-2-内置仓库" class="headerlink" title="3.2 内置仓库"></a>3.2 内置仓库</h3><p> Nexus内置了多个仓库，我们关心的是其中的 maven 仓库，NuGet 是微软推出的一种用于.NET开发的包管理工具，类似于Maven、npm等，这里按下不表。</p>
<p><img src="https://s3.bmp.ovh/imgs/2023/04/24/8ad042040fe2b24a.png" srcset="/img/loading.gif" lazyload></p>
<ul>
<li><p>maven-central:（proxy类型） 用于代理远程仓库，缓存远程仓库中的软件包，减少网络传输开销</p>
<p><img src="https://s3.bmp.ovh/imgs/2023/04/25/fd5eb2197e7d9d4c.png" srcset="/img/loading.gif" lazyload></p>
</li>
<li><p>maven-release: （hosted类型）用于在本地存储发布的 release 版软件包，可以通过该仓库发布自己的软件包（通过设置 pom 文件中的 version，然后通过 maven 的 deploy 命令）</p>
</li>
<li><p>maven-snapshots: （hosted类型）用于在本地存储发布的 snapshots 版软件包，可以通过该仓库发布自己的软件包（通过设置 pom 文件中的 version，然后通过 maven 的 deploy 命令）</p>
</li>
<li><p>maven-public:（group类型） 将多个proxy仓库、hosted仓库和其他group仓库合并成一个虚拟仓库，在使用时就像一个单独的仓库</p>
<p>相比较 proxy 和 hosted 两种类型仓库，创建 group 仓库时需指定成员仓库</p>
<p><img src="https://s3.bmp.ovh/imgs/2023/04/25/82f0a4c9f52f8348.png" srcset="/img/loading.gif" lazyload></p>
</li>
</ul>
<h2 id="4-自定义私有仓库"><a href="#4-自定义私有仓库" class="headerlink" title="4. 自定义私有仓库"></a>4. 自定义私有仓库</h2><p><img src="https://s3.bmp.ovh/imgs/2023/04/24/24ec67552f7f2482.png" srcset="/img/loading.gif" lazyload alt="三种类型仓库"></p>
<ol>
<li>创建一个代理阿里云仓库的私有仓库(proxy类型)：my_nexus</li>
</ol>
<p><img src="https://s3.bmp.ovh/imgs/2023/04/25/8196784d808db409.png" srcset="/img/loading.gif" lazyload></p>
<ol start="2">
<li>创建一个发布版本项目仓库：release  版本(hosted类型)</li>
</ol>
<p><img src="https://s3.bmp.ovh/imgs/2023/04/25/59413c16046f272f.png" srcset="/img/loading.gif" lazyload></p>
<ol start="3">
<li>创建一个快照版本项目仓库：snapshot 版本(hosted类型)</li>
</ol>
<p><img src="https://s3.bmp.ovh/imgs/2023/04/25/6e1dfe96dd05e7a7.png" srcset="/img/loading.gif" lazyload></p>
<ol start="4">
<li>创建一个 group 类型仓库</li>
</ol>
<p><img src="https://s3.bmp.ovh/imgs/2023/04/25/69d2929dd0557abb.png" srcset="/img/loading.gif" lazyload alt="image-20230425135352964"></p>
<h2 id="5-自定义私有仓库的使用"><a href="#5-自定义私有仓库的使用" class="headerlink" title="5. 自定义私有仓库的使用"></a>5. 自定义私有仓库的使用</h2><p>创建是为了使用，接下来让我们看看如何将新创建好的私有仓库应用到项目中：</p>
<h3 id="5-1-代理仓库的使用"><a href="#5-1-代理仓库的使用" class="headerlink" title="5.1 代理仓库的使用"></a>5.1 代理仓库的使用</h3><ol>
<li><p>在私有仓库列表选择一个要使用的私有仓库，拷贝地址备用 </p>
<p><a target="_blank" rel="noopener" href="http://localhost:8081/repository/fengjian-maven-central/">http://localhost:8081/repository/fengjian-maven-central/</a></p>
</li>
<li><p>可以在 setting.xml 文件中 或在 pom.xml 文件中添加私有仓库：<br>该例配置中的releases和snapshots元素比较重要,它们用来控制Maven对于发布版构件<br>和快照版构件的下载。这里需要注意的是enabled子元素,该例中releases 的enabled值为true,表示开启JBoss仓库的发布版本下载支持,<br>而snapshots的enabled值为false,表示关闭 fengjian-maven-central 仓库的快照版本的下载支持。因此,根据<br>该配置,Maven只会从 fengjian-maven-central 仓库下载发布版的构件,而不会下载快照版的构件。</p>
</li>
</ol>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">repositories</span>&gt;</span><br>  <span class="hljs-comment">&lt;!-- 配置私有仓库 --&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">repository</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">id</span>&gt;</span>fengjian-maven-central<span class="hljs-tag">&lt;/<span class="hljs-name">id</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>fengjian-maven-central<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">url</span>&gt;</span>http://localhost:8081/repository/fengjian-maven-central/<span class="hljs-tag">&lt;/<span class="hljs-name">url</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">releases</span>&gt;</span><br>      <span class="hljs-tag">&lt;<span class="hljs-name">enabled</span>&gt;</span>true<span class="hljs-tag">&lt;/<span class="hljs-name">enabled</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">releases</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">snapshots</span>&gt;</span> <br>      <span class="hljs-tag">&lt;<span class="hljs-name">enabled</span>&gt;</span>false<span class="hljs-tag">&lt;/<span class="hljs-name">enabled</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">snapshots</span>&gt;</span><br>  <span class="hljs-tag">&lt;/<span class="hljs-name">repository</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">repositories</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h3 id="5-1-部署仓库的使用"><a href="#5-1-部署仓库的使用" class="headerlink" title="5.1 部署仓库的使用"></a>5.1 部署仓库的使用</h3><p><img src="https://s3.bmp.ovh/imgs/2023/04/26/03df0937e15b6963.png" srcset="/img/loading.gif" lazyload alt="image-20230426004749048"></p>
<p>配置项目部署的远程仓库：release 版本 &amp; snapshot 版本</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">distributionManagement</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">repository</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">id</span>&gt;</span>fengjian-maven-release<span class="hljs-tag">&lt;/<span class="hljs-name">id</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>fengjian-maven-releasee<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">url</span>&gt;</span>http://localhost:8081/repository/fengjian-maven-release/<span class="hljs-tag">&lt;/<span class="hljs-name">url</span>&gt;</span><br>  <span class="hljs-tag">&lt;/<span class="hljs-name">repository</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">snapshotRepository</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">id</span>&gt;</span>fengjian-maven-snapshots<span class="hljs-tag">&lt;/<span class="hljs-name">id</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>fengjian-maven-snapshots<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">url</span>&gt;</span>http://localhost:8081/repository/fengjian-maven-snapshots/<span class="hljs-tag">&lt;/<span class="hljs-name">url</span>&gt;</span><br>  <span class="hljs-tag">&lt;/<span class="hljs-name">snapshotRepository</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">distributionManagement</span>&gt;</span><br></code></pre></td></tr></table></figure>
<p><strong><font color="red">tips</font></strong>:release 和 snapshots 对应的 pom.xml 设置</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-comment">&lt;!-- 快照版本 SNAPSHOT 结尾 --&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>1.0-SNAPSHOT<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span><br><br><span class="hljs-comment">&lt;!-- 稳定版本，非 SNAPSHOT 结尾--&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>2.0-RELEASE<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span><br></code></pre></td></tr></table></figure>





<p><font color="red">部署提示 401，依赖部署到远程仓库需要配置认证信息 </font>  </p>
<p>解决方法：  </p>
<p>在 maven 的 setting.xml 的 <servers> 标签下添加要认证的服务器信息，填写上对应的私有仓库用户名和密码即可</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">servers</span>&gt;</span><br>	<span class="hljs-tag">&lt;<span class="hljs-name">server</span>&gt;</span><br>  	<span class="hljs-tag">&lt;<span class="hljs-name">id</span>&gt;</span>fengjian-maven-release<span class="hljs-tag">&lt;/<span class="hljs-name">id</span>&gt;</span><br>  	<span class="hljs-tag">&lt;<span class="hljs-name">username</span>&gt;</span>admin<span class="hljs-tag">&lt;/<span class="hljs-name">username</span>&gt;</span><br>  	<span class="hljs-tag">&lt;<span class="hljs-name">password</span>&gt;</span>admin123<span class="hljs-tag">&lt;/<span class="hljs-name">password</span>&gt;</span><br>  <span class="hljs-tag">&lt;/<span class="hljs-name">server</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">server</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">id</span>&gt;</span>fengjian-maven-snapshots<span class="hljs-tag">&lt;/<span class="hljs-name">id</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">username</span>&gt;</span>admin<span class="hljs-tag">&lt;/<span class="hljs-name">username</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">password</span>&gt;</span>admin123<span class="hljs-tag">&lt;/<span class="hljs-name">password</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">server</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">servers</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h2 id="6-总结"><a href="#6-总结" class="headerlink" title="6. 总结"></a>6. 总结</h2><p>至此，本文已经提供了 Nexus 搭建和配置 Maven 私有仓库的详细指南。通过这个教程，我们可以轻松地建立自己的 Maven 私有仓库，方便团队内部开发和组织内共享代码。如果有任何问题，请在评论区留言。</p>

            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                  <div class="post-meta mr-3">
                    <i class="iconfont icon-category"></i>
                    
                      <a class="hover-with-bg" href="/categories/%E5%90%8E%E7%AB%AF/">后端</a>
                    
                      <a class="hover-with-bg" href="/categories/%E5%90%8E%E7%AB%AF/maven/">maven</a>
                    
                  </div>
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/maven/">maven</a>
                    
                      <a class="hover-with-bg" href="/tags/%E7%A7%81%E6%9C%89%E4%BB%93%E5%BA%93/">私有仓库</a>
                    
                      <a class="hover-with-bg" href="/tags/Nexus/">Nexus</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">
                  
                    本博客所有文章除特别声明外，均采用 <a target="_blank" href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！
                  
                </p>
              
              
                <div class="post-prevnext">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2023/05/08/%E5%90%8E%E7%AB%AF/java/maven%E4%BD%BF%E7%94%A8%E6%89%8B%E5%86%8C/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">maven 使用手册</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2023/05/08/%E5%90%8E%E7%AB%AF/java/jdk%E5%8A%A8%E6%80%81%E4%BB%A3%E7%90%86/">
                        <span class="hidden-mobile">JDK 动态代理</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
              <!-- Comments -->
              <article class="comments" id="comments" lazyload>
                
                  
                
                
  <div id="SOHUCS" sid='http://example.com/2023/05/08/%E5%90%8E%E7%AB%AF/java/nexus%E6%90%AD%E5%BB%BA%E7%A7%81%E6%9C%89%E4%BB%93%E5%BA%93/'></div>
  <script type="text/javascript">
    Fluid.utils.loadComments('#SOHUCS', function() {
      Fluid.utils.createScript("https://changyan.sohu.com/upload/changyan.js", function() {
        window.changyan.api.config({"appid":"cywjv2D9l","appkey":"2bf2f1231299e92b26393ba6fb2ad9d8"})
      });
    });
  </script>
  <noscript>Please enable JavaScript to view the comments</noscript>


              </article>
            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
    

    
  </main>

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
    风间小栈出品
  </div>
  
  <div class="statistics">
    
    

    
      
        <!-- 不蒜子统计PV -->
        <span id="busuanzi_container_site_pv" style="display: none">
            总访问量 
            <span id="busuanzi_value_site_pv"></span>
             次
          </span>
      
      
        <!-- 不蒜子统计UV -->
        <span id="busuanzi_container_site_uv" style="display: none">
            总访客数 
            <span id="busuanzi_value_site_uv"></span>
             人
          </span>
      
    
  </div>


  

  
</footer>


  <!-- SCRIPTS -->
  
  <script  src="https://cdn.jsdelivr.net/npm/nprogress@0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nprogress@0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js" ></script>
<script  src="https://cdn.jsdelivr.net/npm/bootstrap@4/dist/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>

<!-- Plugins -->


  <script  src="/js/local-search.js" ></script>



  
    <script  src="/js/img-lazyload.js" ></script>
  



  



  
    <script  src="https://cdn.jsdelivr.net/npm/tocbot@4/dist/tocbot.min.js" ></script>
  
  
    <script  src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3/dist/jquery.fancybox.min.js" ></script>
  
  
    <script  src="https://cdn.jsdelivr.net/npm/anchor-js@4/anchor.min.js" ></script>
  
  
    <script defer src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js" ></script>
  



  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>




  <script  src="https://cdn.jsdelivr.net/npm/typed.js@2/lib/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var title = document.getElementById('subtitle').title;
      
        typing(title);
      
    })(window, document);
  </script>















<!-- 主题的启动项 保持在最底部 -->
<script  src="/js/boot.js" ></script>


</body>
</html>
